require('./common/runtime.js')
require('./common/vendor.js')
require('./common/main.js')
App({
  onLaunch: function (options) {
    console.log('App Launch');
    console.log(options)
    if (options.scene === 1047 ||
      options.scene === 1124) { 
      this.globalData.canFocus = true;
    } else {
     
    }

  },
  wxLogin: function () {
    var that = this;
    return new Promise((resolve, reject) => {
      wx.login({
        success: function (res) {
          wx.showLoading({
            mask: true
          })
          var code = res.code;
          wx.request({
            url: that.globalData.requestUrl + '/login', //获取用户id
            // url: that.globalData.requestUrl + '/meco/login', //获取用户id
            // url: 'https://ucode-test-openapi.aax6.cn/auth/mp/login',
            data: {
              code: code,
            },
            method: "POST",
            header: {
              "Content-Type": "application/x-www-form-urlencoded"
            },
            success: function (res) {
              wx.hideLoading();
              if (res.data.code == "success") {
                console.log("sdddsd"+res.data)
                that.globalData.userOpenId = res.data.data.openid;
                that.globalData.jessionId = res.data.data.JSESSIONID;
                that.globalData.userInfo = res.data.data.userinfo
                resolve();
              } else {
                wx.showModal({
                  title: '登录获取失败',
                  content: res.data.msg,
                })
                reject();
              }
            },
            complete: res => {
              console.log(res)
            }
          })
        },
        fail: function () {
          wx.showModal({
            title: '登录失败',
            content: res.data.errcode,
          })
          reject();
        }
      })
    })
  },
  globalData: {
    isFirstLogin: true,
    userInfo: null,
    canFocus:false,
    requestUrl: "https://armeco.happydoit.com",
    userOpenId: null,
    jessionId: null,
    needDownloadFile: ["startrule.jpg", "beizi.gif", "taohua.gif", "taohuapiaosan.gif", "lihui.png"],
    mask1: "https://armeco.happydoit.com/images/mask.png",
    mask2: "https://armeco.happydoit.com/images/mask2.png",
  }
})